import Vue from "vue";
import VueRouter from "vue-router";
import Home from "@/views/Home.vue";

Vue.use(VueRouter);

const routes = [{
    path: "/",
    redirect: '/home'
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
  },
  {
    path: "/list",
    name: "List",
    component: () =>
      import("@/views/List.vue"),
  },
  {
    path: "/cart",
    name: "Cart",
    component: () =>
      import("@/views/Cart.vue"),
  },
  {
    path: "/my",
    name: "My",
    component: () =>
      import("@/views/My.vue"),
  },
  {
    path: "/search",
    component: () =>
      import("@/views/Search.vue"),
    name: "Search",
    children: [
      {
        path: "/",
        name: "Search-index",
        component: () =>
          import("../views/search/Search-index.vue"),
      },
      {
      path: "goods",
      name: "goods",
      component: () =>
        import("@/views/search/Search-list.vue"),
      }
    ]
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;